package com.lzpu.thymeleafproject.demos.service;

import com.lzpu.thymeleafproject.demos.dao.AuthorityRepository;
import com.lzpu.thymeleafproject.demos.dao.CustomerRepository;
import com.lzpu.thymeleafproject.demos.entity.Authority;
import com.lzpu.thymeleafproject.demos.entity.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerService {
    @Autowired
    private CustomerRepository customerRepository;
    @Autowired
    private AuthorityRepository authorityRepository;


    // 业务控制：使用唯一用户名查询用户信息
    public Customer getCustomer(String username){
        Customer customer=null;
        customer = customerRepository.findByUsername(username);
        return customer;
    }
    // 业务控制：使用唯一用户名查询用户权限
    public List<Authority> getCustomerAuthority(String username){
        List<Authority> authorities=null;
        authorities=authorityRepository.findAuthoritiesByUsername(username);
        return authorities;
    }
}
